﻿package util{

    import flash.display.DisplayObject;
    import flash.display.DisplayObjectContainer;
    import flash.filters.BlurFilter;
    import flash.filters.GlowFilter;
    import flash.system.ApplicationDomain;
    import flash.text.TextField;
    import flash.text.TextFormat;
    import flash.text.TextFormatAlign;

    public class DisplayUtil{

        public static function removeChild(parent:DisplayObjectContainer, target:DisplayObject):void{
            if(parent != null && target != null && parent.contains(target)){
				parent.removeChild(target);
			}
        }

        public static function removeAllChild(parent:DisplayObjectContainer, forever:Boolean = false):void{
            if(parent != null){
                while (parent.numChildren > 0){
					var child:DisplayObject = parent.getChildAt(0);
					parent.removeChild(child);
					if(forever){
						child = null;
					}
                }
            }
        }
		
		private static const TITLE_BORDER:GlowFilter = new GlowFilter(0xFFFFFF, 1, 2, 2, 10);
		
		public static function getTitle():TextField {
			var tf:TextField = new TextField();
			var format:TextFormat = new TextFormat("tahoma", 20, 0x653011, true);
			format.align = TextFormatAlign.CENTER;
			tf.width = 200;
			tf.selectable = false;
			tf.defaultTextFormat = format;
			tf.filters= [TITLE_BORDER];
			tf.mouseEnabled = tf.tabEnabled = false;
			return tf;
		}
		
		public static function getMC(dm:ApplicationDomain, name:String):void {
			
		}
    }
}
